//
//  netWorkHandle.m
//  豆瓣
//
//  Created by dllo on 15/11/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "netWorkHandle.h"

@implementation netWorkHandle

+ (void)getDataUnSyWithUrlStr:(NSString *)str block:(void(^)(NSData *))block {
    

    NSString *urlEncode = [str stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
    NSURL *url = [NSURL URLWithString:urlEncode];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
    
    NSURLSessionDataTask *getTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        
        block(data);
        
    }];

    [getTask resume];

}

@end
